package org.example.springblogg.controller;


import lombok.extern.slf4j.Slf4j;
import org.example.springblogg.model.BlogInfo;
import org.example.springblogg.service.BlogService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/blog")
public class BlogController {
    @Autowired
    private BlogService blogService;

    @RequestMapping("/getList")
    public List<BlogInfo> getList(){
        log.info("获取博客列表：");
        return blogService.getList();
    }

    @GetMapping("/getBlogDetail")
    public BlogInfo getBlogDetail(@RequestParam Integer blogId){
        log.info("getBlogDetail, blogId: {}", blogId);
        return blogService.getBlogDetail(blogId);

    }
}
